package cn.jiahui;
/**
 * 电梯的状态
 * @author Administrator
 *
 */
public class LiftState {
	//电梯楼层
	
	/*
	 *
FE
FD
FC
FB
FA
F9
F8
F7
	 */
	int floor;
//	状态 00=无状态
//	01=满载
//			02=管制

	int status;
	
//	方向
//	00=无方向
//			01=上行
//			03=下行
	int dirction;

	public int getFloor() {
		return floor;
	}

	public void setFloor(int floor) {
		this.floor = floor;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getDirction() {
		return dirction;
	}

	public void setDirction(int dirction) {
		this.dirction = dirction;
	}
	
	public void init(byte[] state){
		if(state.length != 11){
			System.out.println("LiftState.init() failed byte[].lenght != 11");
			return;
		}
		floor = (byte)0xFF - state[10-2];
		
		if(state[11-2] == 0x00){
			status = 0;	
		}else if(state[11-2] == 0x01){
			status = 1;
		}else if(state[11-2] == 0x02){
			status = 2;
		}else {
			status = -1;
		}
		
		if(state[12-2] == 0x00){
			dirction = 0;	
		}else if(state[12-2] == 0x01){
			dirction = 1;
		}else if(state[12-2] == 0x02){
			dirction = 3;
		}else {
			dirction = -1;
		}
		
	}

}
